function x = funcEMA(todayClose,daysBack)
% function x = funcEMA(todayClose,daysBack)
% calculate Exponential Moving Average
% default dayBack = 12

if nargin < 2
    daysBack = 12; 
end
alpha = 2 / (daysBack + 1); %calculate smoothing factor "alpha"
coefficient = repmat(1-alpha,1,daysBack).^(1:daysBack); %note 1-alpha
x = filter(coefficient, sum(coefficient), todayClose);
end